﻿package com.sshc625.utils {
	import com.adobe.utils.DictionaryUtil;
	
	import flash.utils.Dictionary;
	public class DictionaryUtil extends com.adobe.utils.DictionaryUtil {
		
		/**
		 * Encode dictionary to url string.
		 * @Usage
		 * var d:Dictionary = new Dictionary(true);
		 * d.name = "sshc625";
		 * d.age = 28;
		 * 
		 * // s is "&name=sshc625&age=28", not name=sshc625&age=28&"
		 * var s:String = DictionaryUtil.urlencode( d );
		 * 
		 * @return url string.
		 */
		public static function urlencode(d:*=null):String {
			if( !(d is Dictionary) && !(d is Object) )	d = null;
			var kv:String = "";
			if(d != null) {
				for(var p:String in d) {
					kv += "&"+p+"="+d[p];
				}
			}
			return kv;
		}
	}
}